home *** CD-ROM | disk | FTP | other *** search
- unit KeyTst2U;
-
- interface
-
- uses
- SysUtils, Windows, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, Spin, ExtCtrls, Buttons;
-
- type
- TForm1 = class(TForm)
- btnDelphi: TButton;
- edtGangScreen: TSpinEdit;
- btnPrintScreen: TButton;
- lblGangScreen: TLabel;
- chkWholeScreen: TCheckBox;
- imgClipBoard: TImage;
- Bevel1: TBevel;
- Edit1: TEdit;
- btnCopyright: TButton;
- procedure btnPrintScreenClick(Sender: TObject);
- procedure chkWholeScreenClick(Sender: TObject);
- procedure edtGangScreenChange(Sender: TObject);
- procedure btnDelphiClick(Sender: TObject);
- procedure btnCopyrightClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- uses
- KeysU2, ClipBrd;
-
- {$R *.DFM}
-
- procedure TForm1.btnPrintScreenClick(Sender: TObject);
- begin
- { Fake press of Print Screen }
- SendKeys(Chr(vk_SnapShot));
- { Get clipboard snapshot onto form's image component }
- imgClipBoard.Picture.Assign(ClipBoard)
- end;
-
- procedure TForm1.chkWholeScreenClick(Sender: TObject);
- begin
- SnapShotWholeScreen := chkWholeScreen.Checked
- end;
-
- procedure TForm1.edtGangScreenChange(Sender: TObject);
- begin
- case edtGangScreen.Value of
- 1: lblGangScreen.Caption := 'Alt+DEVELOPERS';
- 2: lblGangScreen.Caption := 'Alt+TEAM';
- 3: lblGangScreen.Caption := 'Alt+VERSION (Delphi less than 3 only)';
- 4: lblGangScreen.Caption := 'Alt+AND (Delphi 1 only)';
- 5: lblGangScreen.Caption := 'Alt+QUALITY (Delphi 3 upwards only)';
- 6: lblGangScreen.Caption := 'Alt+CHUCK (Delphi 4 only)';
- end
- end;
-
- procedure TForm1.btnDelphiClick(Sender: TObject);
-
- function ScreenHas256ColoursOrMore: Boolean;
- var
- ScreenDC: HDC;
- begin
- ScreenDC := GetDC(HWnd_Desktop);
- try
- Result :=
- GetDeviceCaps(ScreenDC, BitsPixel) *
- GetDeviceCaps(ScreenDC, Planes) >= 8
- finally
- ReleaseDC(HWnd_Desktop, ScreenDC);
- end;
- end;
-
- var
- Wnd: HWnd;
- begin
- Wnd := FindWindow('TAboutBox', 'About Delphi');
- { Get rid of About box if it happens to be up so we know where we are }
- if Wnd <> 0 then
- begin
- BringWindowToTop(Wnd);
- SendKeys(Chr(vk_Escape));
- end;
- { Find Delphi's main window - note the Delphi }
- { caption changes, so we'll use nil }
- Wnd := FindWindow('TAppBuilder', nil);
- if Wnd = 0 then
- Exit;
- { If Delphi is minimised, this statement may have no visible effect }
- BringWindowToTop(Wnd);
- { Delphi 1 has four About box gang screens, Delphi 2 has three }
- { Delphi 3 has three and Delphi 4 has four. The fourth one }
- { (Delphi 1 only) only works on >=256 colour screen drivers }
-
- SendKeys(Chr(vk_Menu)+'HA'); { Invoke the About box: Help | About }
- PressKey(Char(vk_Menu)); { Hold down Alt key }
- case edtGangScreen.Value of
- 1: SendKeys('DEVELOPERS');
- 2: SendKeys('TEAM');
- 3: SendKeys('VERSION');
- 4: if ScreenHas256ColoursOrMore then
- SendKeys('AND')
- else
- MessageDlg(
- 'Alt+AND (Delphi 1 only) requires at least a 256-colour driver',
- mtInformation, [mbOk], 0);
- 5: SendKeys('QUALITY');
- 6: SendKeys('CHUCK');
- end;
- ReleaseKey(Char(vk_Menu)); { Release Alt key }
- end;
-
- procedure TForm1.btnCopyrightClick(Sender: TObject);
- begin
- { The intention here is to enter the string: }
- { Copyright: ⌐ }
- { into the edit control. This requires some planning }
- { to get the mixed case, as well as the colon character }
-
- { Give focus to edit }
- Edit1.SetFocus;
- { Make sure Caps Lock is off }
- if Odd(GetKeyState(vk_Capital)) then
- SendKeys(Chr(vk_Capital));
- { Hold down Shift key, press C, then release Shift }
- PressKey(Chr(vk_Shift));
- SendKeys('C');
- ReleaseKey(Chr(vk_Shift));
- { Press more keys (which will be lower case) }
- SendKeys('OPYRIGHT');
- { Hold down Shift key, press ;, then release Shift }
- PressKey(Chr(vk_Shift));
- SendKeys(#$BA);
- ReleaseKey(Chr(vk_Shift));
- { Send a space character }
- SendKeys(Chr(vk_Space));
- { Do Alt+0169 on number pad }
- PressKey(Chr(vk_Menu));
- SendKeys(Chr(vk_Insert) + Chr(vk_End) + Chr(vk_Right) + Chr(vk_Prior));
- ReleaseKey(Chr(vk_Menu))
- end;
-
- end.
-